package com.kun.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kun.index.entity.BlogLabel;
import com.kun.index.mapper.BlogLabelMapper;
import com.kun.index.service.BlogLabelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 博客_标签表 服务实现类
 * </p>
 *
 * @author kunkun
 * @since 2024-03-18
 */
@Service
public class BlogLabelServiceImpl extends ServiceImpl<BlogLabelMapper, BlogLabel> implements BlogLabelService {

    @Autowired
    private BlogLabelMapper blogLabelMapper;

    @Override
    public Integer addBlogLabel(BlogLabel blogLabel) {
        return blogLabelMapper.insert(blogLabel);
    }

    @Override
    public Integer deleteBlogLabel(Integer labelId) {
        QueryWrapper<BlogLabel> wrapper = new QueryWrapper<>();
        wrapper.eq("labelId",labelId);
        return blogLabelMapper.delete(wrapper);
    }

    @Override
    public List<BlogLabel> queryByLabelId(Integer labelId) {
        QueryWrapper<BlogLabel> wrapper = new QueryWrapper<>();
        wrapper.eq("labelId",labelId);
        return blogLabelMapper.selectList(wrapper);
    }

    @Override
    public List<BlogLabel> queryByBlogId(Integer blogId) {
        QueryWrapper<BlogLabel> wrapper = new QueryWrapper<>();
        wrapper.eq("blogId",blogId);
        return blogLabelMapper.selectList(wrapper);
    }

    @Override
    public Integer deleteBlogLabelByBlogId(Integer blogId) {
        QueryWrapper<BlogLabel> wrapper = new QueryWrapper<>();
        wrapper.eq("blogId",blogId);
        return blogLabelMapper.delete(wrapper);
    }
}
